package sis.util;/*
 * @auther 顶风少年
 * @mail dfsn19970313@foxmail.com
 * @date 2019-08-01 10:36
 * @notify
 * @version 1.0
 */

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

//向 TXT写入内容
public class LineWriter {
    public static void write(String filename, String[] records) throws IOException {
        BufferedWriter writer = null;
        try {
            //字符流输入流缓冲区 接收一个字符流
            writer = new BufferedWriter(new FileWriter(filename));
            //遍历所要写入的 数组
            for (int i = 0; i < records.length; i++) {
                //写一行
                writer.write(records[i]);
                //换行符
                writer.newLine();
            }
        } finally {
            //关闭流
            if (writer != null) {
                writer.close();
            }
        }
    }
}
